package com.mryin.performance.config;

import com.mryin.performance.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: PerformanceManager
 * @description: 登录拦截器
 * @author: Mr.YIN
 * @create: 2021-03-03 12:58
 **/
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        System.out.println(1);
        registry.addViewController("/login").setViewName("login");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println(1);
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/login","/login.html","/doLogin")
                .excludePathPatterns("/plugins/**")
                .excludePathPatterns("/layui/**")
                .excludePathPatterns("/jquery-3.4.1/**");
    }
}
